package me.zhengjie.utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GetSndj {

    public static final String SNDJ = "SNDJ";
    public static final String DYQX = "DYQX";
    public static final String SNDJ_CODE = "SNDJ_CODE";

    /**
     * 2025年评估表准
     * @param c1
     * @param c2
     * @param c3
     * @param nl
     * @return
     */
    public static Map<String, String> analyse(int c1, int c2, int c3, int nl) {

        Map<String, String> map = new HashMap<>();
        int c1_dj = 0;
        if(c1 <= 40) {

            c1_dj = 4;
        } else if(c1>=41 && c1<=60) {

            c1_dj = 3;
        } else if(c1>=61 && c1<=99) {

            c1_dj = 2;
        } else {

            c1_dj = 1;
        }
        int c2_dj = 0;
        if(c2 <= 1) {

            c2_dj = 4;
        } else if(c2>=2 && c2<=3) {

            c2_dj = 3;
        } else if(c2>=4 && c2<=15) {

            c2_dj = 2;
        } else {

            c2_dj = 1;
        }
        int c3_dj = 0;
        if(c3 <= 1) {

            c3_dj = 4;
        } else if(c3>=2 && c3<=3) {

            c3_dj = 3;
        } else if(c3>=4 && c3<=11) {

            c3_dj = 2;
        } else {

            c3_dj = 1;
        }

        int c2c3_dj = c2_dj >= c3_dj ? c2_dj : c3_dj;

        if(c1_dj == 1 && c2c3_dj == 1) {
            if(nl >= 90) {
                map.put(SNDJ, "90周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else if (nl >= 85 && nl < 90) {
                map.put(SNDJ, "85周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else {
                map.put(SNDJ, "基本正常");
                map.put(DYQX, "0");
                map.put(SNDJ_CODE, "0");
            }
        } else if(c1_dj == 1 && c2c3_dj == 2) {
            if(nl >= 90) {
                map.put(SNDJ, "90周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else if (nl >= 85 && nl < 90) {
                map.put(SNDJ, "85周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else {
                map.put(SNDJ, "基本正常");
                map.put(DYQX, "0");
                map.put(SNDJ_CODE, "0");
            }
        } else if(c1_dj == 1 && c2c3_dj == 3) {
            if(nl >= 90) {
                map.put(SNDJ, "90周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else if (nl >= 85 && nl < 90) {
                map.put(SNDJ, "85周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else {
                map.put(SNDJ, "轻度失能");
                map.put(DYQX, "0");
                map.put(SNDJ_CODE, "1");
            }
        } else if(c1_dj == 1 && c2c3_dj == 4) {
            if(nl >= 90) {
                map.put(SNDJ, "90周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else if (nl >= 85 && nl < 90) {
                map.put(SNDJ, "85周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else {
                map.put(SNDJ, "轻度失能");
                map.put(DYQX, "0");
                map.put(SNDJ_CODE, "1");
            }
        } else if(c1_dj == 2 && c2c3_dj == 1) {
            if(nl >= 90) {
                map.put(SNDJ, "90周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else if (nl >= 85 && nl < 90) {
                map.put(SNDJ, "85周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else {
                map.put(SNDJ, "轻度失能");
                map.put(DYQX, "0");
                map.put(SNDJ_CODE, "1");
            }
        } else if(c1_dj == 2 && c2c3_dj == 2) {
            if(nl >= 90) {
                map.put(SNDJ, "90周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else if (nl >= 85 && nl < 90) {
                map.put(SNDJ, "85周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else {
                map.put(SNDJ, "轻度失能");
                map.put(DYQX, "0");
                map.put(SNDJ_CODE, "1");
            }
        } else if(c1_dj == 2 && c2c3_dj == 3) {
            if(nl >= 90) {
                map.put(SNDJ, "90周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else if (nl >= 85 && nl < 90) {
                map.put(SNDJ, "85周岁以上");
                map.put(DYQX, "12");
                map.put(SNDJ_CODE, "1");
            } else {
                map.put(SNDJ, "轻度失能");
                map.put(DYQX, "0");
                map.put(SNDJ_CODE, "1");
            }
        } else if(c1_dj == 2 && c2c3_dj == 4) {
            map.put(SNDJ, "中度失能");
            map.put(DYQX, "6");
            map.put(SNDJ_CODE, "2");
        } else if(c1_dj == 3 && c2c3_dj == 1) {
            map.put(SNDJ, "中度失能");
            map.put(DYQX, "6");
            map.put(SNDJ_CODE, "2");
        } else if(c1_dj == 3 && c2c3_dj == 2) {
            map.put(SNDJ, "中度失能");
            map.put(DYQX, "6");
            map.put(SNDJ_CODE, "2");
        } else if(c1_dj == 3 && c2c3_dj == 3) {
            map.put(SNDJ, "中度失能");
            map.put(DYQX, "6");
            map.put(SNDJ_CODE, "2");
        } else if(c1_dj == 3 && c2c3_dj == 4) {
            map.put(SNDJ, "重度失能Ⅰ级");
            map.put(DYQX, "6");
            map.put(SNDJ_CODE, "3");
        } else if(c1_dj == 4 && c2c3_dj == 1) {
            map.put(SNDJ, "重度失能Ⅰ级");
            map.put(DYQX, "6");
            map.put(SNDJ_CODE, "3");
        } else if(c1_dj == 4 && c2c3_dj == 2) {
            map.put(SNDJ, "重度失能Ⅰ级");
            map.put(DYQX, "6");
            map.put(SNDJ_CODE, "3");
        } else if(c1_dj == 4 && c2c3_dj == 3) {
            map.put(SNDJ, "重度失能Ⅱ级");
            map.put(DYQX, "12");
            map.put(SNDJ_CODE, "4");
        } else if(c1_dj == 4 && c2c3_dj == 4) {
            map.put(SNDJ, "重度失能Ⅲ级");
            map.put(DYQX, "24");
            map.put(SNDJ_CODE, "5");
        }

        return map;
    }

    public static Map<String, String> analyse(int score, int nl) {

        Map<String, String> map = new HashMap<>();

        if(score <= 20) {
            map.put(SNDJ, "重度失能");
            map.put(DYQX, "12");
        } else if(score > 20 && score <= 30) {
            map.put(SNDJ, "重度失能");
            map.put(DYQX, "12");
        } else if(score > 30 && score <= 40) {
            map.put(SNDJ, "重度失能");
            map.put(DYQX, "6");
        } else if(score > 40 && score <= 60) {
            map.put(SNDJ, "中度失能");
            map.put(DYQX, "6");
        } else if(score > 60) {
            if(nl >= 90) {
                map.put(SNDJ, "90周岁以上");
                map.put(DYQX, "6");
            } else if (nl >= 85 && nl < 90) {
                map.put(SNDJ, "85周岁以上");
                map.put(DYQX, "12");
            } else {
                map.put(SNDJ, "不符合失能条件");
                map.put(DYQX, "0");
            }
        }

        return map;
    }



    public static Map<String, String> ana2lyse(int score, int nl) {

        Map<String, String> map = new HashMap<>();
        if(nl >= 90) {
            map.put(SNDJ, "90周岁以上");
            map.put(DYQX, "6");
        } else if (nl >= 85 && nl < 90) {
            map.put(SNDJ, "85周岁以上");
            map.put(DYQX, "12");
        } else {
            if(score <= 20) {
                map.put(SNDJ, "重度失能");
                map.put(DYQX, "24");
            } else if(score > 20 && score <= 30) {
                map.put(SNDJ, "重度失能");
                map.put(DYQX, "12");
            } else if(score > 30 && score <= 40) {
                map.put(SNDJ, "重度失能");
                map.put(DYQX, "6");
            } else if(score > 40 && score <= 60) {
                map.put(SNDJ, "中度失能");
                map.put(DYQX, "6");
            } else if(score > 60) {
                map.put(SNDJ, "不符合失能条件");
                map.put(DYQX, "0");
            }
        }


        return map;
    }
}
